package cn.stylefeng.guns.modular.course.wrapper;


import cn.stylefeng.guns.modular.course.entity.Category;
import cn.stylefeng.guns.modular.course.service.CategoryService;

import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.base.warpper.BaseControllerWrapper;
import cn.stylefeng.roses.core.util.SpringContextHolder;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.Date;
import java.util.List;
import java.util.Map;


public class CourseWarpper extends BaseControllerWrapper {
    public CourseWarpper(Page<Map<String, Object>> page) {
        super(page);
    }

    private CategoryService categoryService= SpringContextHolder.getBean(CategoryService.class);

    @Override
    protected void wrapTheMap(Map<String, Object> map) {
        Integer categoryId=(Integer)map.get("categoryId");
        Category category=categoryService.getById(categoryId);
        Category parenttCategory=categoryService.getById(category.getPid());
        map.put("categoryName",category.getName());
        map.put("categoryParentName",parenttCategory.getName());



    }
}
